/**
 * Project Name:javaBaseReview
 * Package Name:com.xuwei.base.thread
 * author:David
 * Date:2015年8月19日上午7:44:50
 * Copyright (c) 2015, xw123box@126.com All Rights Reserved.
 *
 */
package com.xuwei.base.thread;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author David
 * @since 2015年8月19日 上午7:44:50
 * @version 
 * @since JDK 1.6
 */
public class TraditionalTimerTest {
	private static int count=0;
	public static void main(String[] args) {
		/*new Timer().schedule(new TimerTask() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				System.out.println("bombing!");
			}
		}, 10000,3000);*/
		
	
		class MyTimerTask extends TimerTask{
			@Override
			public void run() {
				count=(count+1)%2;
				// TODO Auto-generated method stub
				System.out.println("bombing!");
				new Timer().schedule(/*new TimerTask() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						System.out.println("bombing!");
					}
				}*/new MyTimerTask(), 2000*(1+count));
				
			}
		}
		
		new Timer().schedule(new MyTimerTask(), 2000);
		
		while(true){
			System.out.println(new Date().getSeconds());
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
}
